package com.xingshang.config;

import com.xingshang.interceptor.LoginAdminInterceptor;
import com.xingshang.interceptor.LoginUserInterceptor;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
@RequiredArgsConstructor
public class WebMvcConfig implements WebMvcConfigurer {


    private final LoginUserInterceptor loginUserInterceptor;
    private final LoginAdminInterceptor loginAdminInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //排除user/wxlogin 接口
        registry.addInterceptor(loginUserInterceptor)
                .addPathPatterns("/cart/**")
                .addPathPatterns("/order/**")
        ;
        registry.addInterceptor(loginAdminInterceptor)
                .addPathPatterns("/admin/**")
        ;
    }


}
